class LongStrings(object):
    '''
    Reads long strings for cutscenes...easier than doing it all in one place.
    '''
    
    def readFile(self, file):
        char = file.read(1)
        strings = dict()
        while char:#will be None at EOF
            key = ""
            text = ""
            lookback = ["",""]#[0] previous, [1] 2 before
            inString = False
            end = False
            while not end:#skip whitespace
                if char == "." and not inString:
                    while char and not char == "=":
                        key += char
                        char = file.read(1)
                    key = key[1:].strip()#remove initial "."
                if (char == "'" and lookback[0]=="'" and lookback[1]=="'"):
                    if inString:
                        end = True
                    if not inString:
                        inString = True
                    lookback = ["",""]#escape token completed, reset
                else:
                    if inString:
                        text += lookback[1]
                    lookback[1] = lookback[0]
                    lookback[0] = char
                char = file.read(1)
            strings[key]=text.strip();
        return strings
            
    def getString(self,key):
        if key in self.strings:
            return self.strings[key]
        return None
            

    def __init__(self, stringsFileName):
        sf = open(stringsFileName)
        self.strings = self.readFile(sf)
        